define(["backbone", "models/${domainClass}Model", "vent" ], function(Backbone, ${capDomainClass}, vent) {

	var ${capDomainClass}Collection = Backbone.Collection.extend({
		
		 	url: "/${appName}/${domainClass}s",
			 
			model:${capDomainClass},
			
			comparator : function(field) {
				return field.get('name');
			},
		
			allModels: null,
			
			firstTimeFilter : true,
			
			filterByName: function(name){
				
				if(this.firstTimeFilter){
					
					this.allModels = this.models;
					this.firstTimeFilter = false;
					
				}else{
					this.models = this.allModels;
				}
				
				this.reset( this.models.filter(
					function(c) { 
						
						if(name == ""){
							return true;
						}
						
						return c.get('name').indexOf(name) != -1; 
					}
				));
				
			},
			
		push : function(model){
			this.allModels.push(model);
		}
	});
	
	
	return ${capDomainClass}Collection;
});